package com.black.cat.jvm.rtda.heap.methodarea;

public class MethodLookup {

    static public JMethod lookupMethodInClass(JClass clazz, String name, String descriptor) {
        for (JClass c = clazz; c != null; c = c.superJClass) {
            for (JMethod method : c.JMethods) {
                if (method.name.equals(name) && method.descriptor.equals(descriptor)) {
                    return method;
                }
            }
        }
        return null;
    }

    static public JMethod lookupMethodInInterfaces(JClass[] ifaces, String name, String descriptor) {
        for (JClass inface : ifaces) {
            for (JMethod method : inface.JMethods) {
                if (method.name.equals(name) && method.descriptor.equals(descriptor)) {
                    return method;
                }
            }
        }
        return null;
    }

}
